package com.zhou.common.template.project.controller;

import com.zhou.base.components.bs.common.exception.base.BaseExceptionBuilder;
import com.zhou.base.components.bs.common.model.Response;
import com.zhou.common.template.project.model.ao.UserAo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @Validated 在类上要想生效得加上spring-boot-starter-validation
 * @description:
 * @author xianfeng
 * @date 2023/12/2 16:17
 */
//@Validated
@RequiredArgsConstructor
@Slf4j
@RestController
@RequestMapping("/i18n/test")
public class I18nTestController {
    @GetMapping("/testWithI18n")
    public Response testWithI18n() {
        if (1 == 1) {
            throw BaseExceptionBuilder.messageCode("test").args("param1", "param2");
        }
        return Response.success();
    }

    @GetMapping("/testWithoutI18n")
    public Response testWithoutI18n() {
        if (1 == 1) {
            throw BaseExceptionBuilder.message("test");
        }
        return Response.success();
    }

    @PostMapping("/testPostParamError")
    public Response testPostParamError(@Valid @RequestBody UserAo ao) {
        return Response.success(ao);
    }
}
